import React from 'react';
import $ from 'jquery';
import {BrowserRouter as Router,Route,NavLink,Prompt} from 'react-router-dom';
import '../css/classify.css';
import '../css/iconfont.css';




class Classify extends React.Component{
	constructor(props){
		super(props)
		this.state={
			list:[],
			
		}
	}
	
	
	
	
	render(){
		return(
			<div className="classify">
				<header className="tou">商品分类</header>
				<section>
					<ul className="nav">
						<li>西药</li>
						<li>中药</li>
						<li>保健品</li>
						<li>医疗器械</li>
						<li>其他</li>
					</ul>
					<ul className="pro-list">
                            {
                                	this.state.list.map(function(item,i){
                                        return(
                                            <li>
                                                <NavLink to={"/detail/"+item.pid}>
                                                    <div><img src={item.pimg}/></div>
                                                    <div>
                                                        <p>{item.pname}</p>
                                                        <p>{item.pdesc}</p>
                                                        <p><span>建议零售价：￥{item.pprice}</span><button class="iconfont icon-gouwucheman"></button></p>
                                                    </div>
                                                </NavLink>
                                            </li>
                                        )
                                    })
                            }
                           
                    </ul>
				</section>
			</div>	
        )
    }



componentWillMount(){
	var _this=this;
	$.ajax({
		type:"get",
		url:"http://jx.xuzhixiang.top/ap/api/productlist.php",
		data:{uid:"14632"},
		async:false,
		dataType:'json',
		success:function(data){
			console.log(data.data)
			_this.setState({list:data.data})
			
		}
	})
}
}
export default Classify